﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using DDD从零起步.Controllers;
using Domain.Service.Order;

using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DDD从零起步.test
{
    using Domain.Entities;
    using Domain.Core;
    using Domain.Core.Fakes;
    using Infrastructure;
    [TestClass]
    public class CategoryControllerTest : Controller
    {
        IRepository<Order_Info> iRepository;
        Order_Info entity = null;
        static int UserID = 0;
        public CategoryControllerTest()
        {
            iRepository = new BackgroundRepository<Order_Info>();
        }

        [ClassInitialize()]
        public static void Initialize(TestContext testContext)
        {
            UserID = 11;
        }

        [TestMethod]
        public void 得到所有订单信息()
        {
            var order = iRepository.GetEntities();
            Assert.IsNotNull(order);
            order.ToList().ForEach(i =>
            {
                Console.WriteLine(i.OrderID + " " + i.UserID + " " + i.CreateDate);
            });

        }
        [TestMethod]
        public void 添加一个订单()
        {
            entity = new Order_Info
            {
                CreateDate = DateTime.Now,
                UserID = UserID,
                OrderID = 12,
            };
            iRepository.Add(entity);
        }
        [TestMethod]
        public void 订单查询()
        {

        }
        [TestMethod]
        public void 删除一个订单(Order_Info entity)
        {
            Console.WriteLine("要删除的实体ID：" + entity.OrderID);
            iRepository.Remove(entity);
        }
    }
}
